package com.guyu.plugin.mybatis.entity;

import com.guyu.common.core.enums.YesOrNoEnum;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.Objects;

@Data
public class BaseBO {

    /**
     * 创建者
     */
    protected Long createBy;
    /**
     * 创建时间
     */
    protected LocalDateTime createTime;
    /**
     * 更新者
     */
    protected Long updateBy;
    /**
     * 更新时间
     */
    protected LocalDateTime updateTime;
    /**
     * 删除字段
     *
     * @see YesOrNoEnum
     */
    protected boolean deleted;

    public void from(BaseDO baseDO) {
        if (Objects.isNull(baseDO)) {
            return;
        }
        this.createBy = baseDO.getCreateBy();
        this.createTime = baseDO.getCreateTime();
        this.updateBy = baseDO.getUpdateBy();
        this.updateTime = baseDO.getUpdateTime();
        this.deleted = YesOrNoEnum.isYes(baseDO.getDeleted());
    }
}